using System;
using System.Runtime.InteropServices;

namespace ICSharpCode.TextEditor
{
    public class NativeMethods
    {
        [StructLayout(LayoutKind.Sequential)]
        public class Scrollinfo
        {
            public int fMask;

            public int nMin;

            public int nMax;

            public int nPage;

            public int nPos;

            public int cbSize;

            public int nTrackPos;

            public Scrollinfo()
            {
                cbSize = Marshal.SizeOf(typeof(Scrollinfo));
            }

            public Scrollinfo(int mask, int min, int max, int page, int pos)
                : this()
            {
                fMask = mask;
                nMin = min;
                nMax = max;
                nPage = page;
                nPos = pos;
            }
        }

        internal const int SB_CTL = 2;

        internal const int SIF_ALL = 23;

        internal const int WHEEL_DELTA = 120;

        internal const int WHEEL_MAX_DELTA = 120;

        [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern bool GetScrollInfo(HandleRef hWnd, int fnBar, Scrollinfo si);

        [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern int SetScrollInfo(HandleRef hWnd, int fnBar, Scrollinfo si, bool redraw);

        [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr wnd, int msg, bool param, int lparam);
    }
}
